<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0 maximum-scale=1.0, user-scalable=no">
    <meta HTTP-EQUIV="pragma" CONTENT="no-cache">
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-store, must-revalidate">
    <meta HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta HTTP-EQUIV="expires" CONTENT="0">
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/index.css">
    <title>订货中心</title>
    <style media="screen">
        body {
            background-color: #f4f4f4;
            font-size: 0.2rem;
        }

        [v-cloak] {
            display: none !important;
        }
    </style>
</head>

<body>
<div class="loadingBack  uhide">
    <div id="loading" class="loading">
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
    </div>
</div>
<div id="Order">
    <ul class="order-center" v-cloak>
        <li v-for="(item,index) in orderResult" >
            <img src="image/ewm.jpg" alt="" class="ewmClass" @click="ewmShow(item)">
            <div @click="gotoOrderDetail(item)">
                <p class="tit">{{item.custName}}</p>
                <p class="cont"><span>累计下单数：</span><span class="orange-ft">{{item.orderCount}} </span><span>笔</span></p>
                <p class="cont"><span>累计下单金额：</span><span class="orange-ft">{{item.orderPriceSum}} </span><span>元</span></p>
                <span class="icon-skip">></span>
            </div>
        </li>
    </ul>
    <div v-bind:class="{dn:ishow}"  @click="ewmClose()">
        <div class="cover-box"></div>
        <div class="ewm-box">
            <p class="tit" style="text-align: center;font-size: 0.4rem;">{{ tit }}</p>
            <div id="qrcode" class="qrcode" style="width: 80%;margin: 0 auto"></div>
            <p style="font-size: 0.3rem;">扫一扫上面的二维码图案，去下单</p>
        </div>

    </div>

</div>

</body>
<script type="text/javascript">
    !function () {
        var ua = navigator.userAgent.toLowerCase();
        if (/iphone|ipad|ipod/.test(ua)) {
            var sc = 1 / window.devicePixelRatio;
            document.getElementsByName('viewport')[0].content = 'initial-scale=' + sc + ', maximum-scale=' + sc + ', minimum-scale=' + sc + ', user-scalable=no';
        }
        var pxUnit = 100;
        var designWid = 750;
        var winWid = document.body.clientWidth;
        var winHei = document.body.clientHeight;
        var bl = winWid / designWid;
        document.querySelector('html').style.fontSize = (bl * pxUnit) + 'px';
    }();
</script>
<script src="js/vue.min.js"></script>
<!--<script src="js/vue-resource.min.js"></script>-->
<script src="js/zepto.min.js"></script>
<script src="js/common.js"></script>
<script src="js/jquery.qrcode.min.js"></script>
<script>
    (function () {
        if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
            handleFontSize();
        } else {
            if (document.addEventListener) {
                document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
            } else if (document.attachEvent) {
                document.attachEvent("WeixinJSBridgeReady", handleFontSize);
                document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
            }
        }

        function handleFontSize() {
            // 设置网页字体为默认大小
            WeixinJSBridge.invoke('setFontSizeCallback', {
                'fontSize': 0
            });
            // 重写设置网页字体大小的事件
            WeixinJSBridge.on('menu:setfont', function () {
                WeixinJSBridge.invoke('setFontSizeCallback', {
                    'fontSize': 0
                });
            });
        }
    })();
</script>
<script>
    var app = new Vue({
        el: '#Order',
        data: {
            orderResult: [],
            openId: '',
            fairsInfoId: '',
            ishow:true,
            tit: '公司名称获取失败'
        },
        mounted: function () {
            var user = JSON.parse(localStorage.getItem('signUserInfo') || '{}');
            this.fairsInfoId = localStorage.getItem('SignWebFairsInfoId');
            this.openId = user.openId;
            if (this.openId && this.fairsInfoId) {
                this.getOrderCenter();
            }
        },
        methods: {
            getOrderCenter: function () {
                var that = this;
                vueRequest('/cust/sign/orderCenter', {
                    openId: this.openId,
                    fairsInfoId: this.fairsInfoId
                }, this, function (result, that) {
                    that.orderResult = result.orderResult;
                });
            },
            gotoOrderDetail: function (item) {
                localStorage.setItem('custName', item.custName);
                localStorage.setItem('isLevelTwo', item.isLevelTwo);
                localStorage.setItem('danwBh', item.danwBh);
                localStorage.setItem('danwNm', item.danwNm);
                window.location.href="orderDetail.html";


            },
            ewmShow:function (item) {              
                vueRequest('/cust/sign/getQRCodeInfo', {
                    danwBh: item.danwBh||'',
                    danwNm: item.danwNm||'',
                    isLevelTwo:item.isLevelTwo,
                    branchId:item.branchId
                }, this, function (result, that) {              
                  if(!result.content){
                    alert('二维码生成失败！');
                    return;
                  }
                  that.tit = item.custName;
                  that.ishow = false;
                    $('#qrcode').qrcode({
                        text:result.content,
                    });
                });
            },
            ewmClose:function () {
                this.ishow = true;
                $('canvas').remove()
            }

        }
    })

</script>

</html>